/*
 * usart2.c
 *
 *  Created on: Mar 3, 2020
 *      Author: hp
 */

#include "main.h"
#include "usart2.h"

extern uint8_t  USART2_RX_BUF[USART2_MAX_RECV_LEN]; 		//接收缓冲
extern uint8_t  USART2_TX_BUF[USART2_MAX_SEND_LEN]; 		//发送缓冲
extern uint16_t USART2_RX_STA;   						//received data status

extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;

extern DMA_HandleTypeDef hdma_usart2_rx;

extern uint8_t USART1_RX_BUF[128];
extern uint8_t USART1_RX_STA;

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
   if(huart == &huart2)  //判断是否是串口2
   {
        HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_5);
        //切换uart2到接收模式
        HAL_UART_Receive_DMA(huart, USART2_RX_BUF, USART2_MAX_RECV_LEN);
   }
}


void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
	if(huart == &huart1) {
//		u2_printf(USART1_RX_BUF);
//		USART1_RX_STA = 0;
	}
	else if(huart == &huart2) {
		u2_printf("HAL_UART_RxCpltCallback: %s", USART2_RX_BUF);
//		USART2_RX_STA = 1;
	}
}
